﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using System.Data.SqlClient;
using DAO;
using DTO;
namespace Banking.Quản_lý
{
    public partial class XemChiTietChucVu : Form
    {
        private ChucVu chucVu;
        private int type;
        public XemChiTietChucVu(int _type)
        {
            InitializeComponent();
            type = _type;
        }

        public void init(int ma)
        {
            List<int> lst = ChucVuDAO.GetDelFlg();
            cbbDel.DataSource = lst;
            chucVu = ChucVuDAO.GetById(ma);
            BuildBinding();
            
        }


        private void BuildBinding()
        {
            if (chucVu != null)
            {
                txtMa.DataBindings.Add("Text", chucVu, "MaChucVu");
                txtMoTa.DataBindings.Add("Text", chucVu, "MoTa");
                dateNgayCapNhat.DataBindings.Add("Value", chucVu, "LastUpdate");
                cbbDel.DataBindings.Add("SelectedText", chucVu, "DelFlg");
            }

        }

        private void btnCapNhat_Click(object sender, EventArgs e)
        {
            ChucVuDAO.UpdateChucVu(chucVu,type);
            MessageBox.Show("Update thành công, trạng thái đã được thay đổi");
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
